from random import *

def PutWordsInList(WordType):
    File = open("%s.txt" %str(WordType), 'r')
    List = []
    for eachLine in File:
        List.append(eachLine)
    print len(List), str(WordType), "loaded."
    return List

def GetRandomWord(WordType):
    Int = randrange(len(WordType))
    RandomWord = WordType[Int].strip()
    return RandomWord

LengthOfSentences = []
Nouns = PutWordsInList("Nouns")
Verbs = PutWordsInList("Verbs")
Adverbs = PutWordsInList("Adverbs")
Adjectives = PutWordsInList("Adjectives")

print "\n", len(Nouns)+len(Verbs)+len(Adverbs)+len(Adjectives), "total words loaded."
print "That's over ", len(Nouns)*len(Verbs)*len(Adverbs)*len(Adjectives), "combinations!"

print"\n****************************************\n"

while True:
    howmany = raw_input("How many sentences do you want?")
    print ""
        
    for i in range(int(howmany)):

        print i+1, " ",

        RandomNoun = GetRandomWord(Nouns)
        RandomVerb = GetRandomWord(Verbs)
        RandomAdjective = GetRandomWord(Adjectives)
        RandomAdverb = GetRandomWord(Adverbs)

        RandInt = randrange(6)
        if RandInt == 0:
            RandSent = "Is " + RandomNoun + " " + RandomVerb + "?"
            print RandSent, "-", len(RandSent), "characters long."
            LengthOfSentences.append(len(RandSent))
        if RandInt == 1:
            RandSent = RandomNoun + " is " + RandomVerb + "."
            print RandSent, "-", len(RandSent), "characters long."
            LengthOfSentences.append(len(RandSent))
        if RandInt == 2:
            RandSent = "The " + RandomAdjective + " " + RandomNoun + " is " + RandomVerb + "."
            print RandSent, "-", len(RandSent), "characters long."
            LengthOfSentences.append(len(RandSent))
        if RandInt == 3:
            RandSent =  "A " + RandomNoun + " " + RandomVerb + " " + RandomAdverb + "."
            print RandSent, "-", len(RandSent), "characters long."
            LengthOfSentences.append(len(RandSent))
        if RandInt == 4:
            RandSent = RandomNoun + " " + RandomVerb + " " + RandomAdverb + "!"
            print RandSent, "-", len(RandSent), "characters long."
            LengthOfSentences.append(len(RandSent))
        if RandInt == 5:
            RandSent = "Why is the " + RandomNoun + " " + RandomAdjective + "?"
            print RandSent, "-", len(RandSent), "characters long."
            LengthOfSentences.append(len(RandSent))

    LengthOfSentences.sort()
    print "\nThe average sentence is " + str(sum(LengthOfSentences)/len(LengthOfSentences)) + " letters long."
    print "The longest sentence was " + str(LengthOfSentences[-1]) + " letters long."
    print "The shortest sentence was " + str(LengthOfSentences[0]) + " letters long.\n"
